let authorization;
var txtLoginId = new VerifyTheForm("txtLoginId", async function (val) {
    // console.log("输出");
    // let err = await login(val);
    // console.log(err)
    if (!val) {
        return "账号不能为空";
    } else {
        return false;
    }
    //  else if (err.code != 0) {
    //     return err.msg;
    // } else if (err.code == 0) {
    //     if (err.data) {
    //         return "账号或密码错误";
    //     } else {
    //         return false;
    //     }
    // }
})
let txtLoginPwd = new VerifyTheForm("txtLoginPwd", async function (val) {
    if (!val) {
        return "密码不能为空"
    } else {
        return false;
    }
})
let Ufrom = document.querySelector(".user-form");
Ufrom.addEventListener("submit", async function (e) {
    e.preventDefault();
    let jg = await VerifyTheForm.validationSucceeded(txtLoginId, txtLoginPwd);
    if (jg) {
        fromName();

    }
})
function fromName() {
    let from = new FormData(Ufrom);
    let obj = Object.fromEntries(from.entries())
    console.log(obj);
    login(obj).then((data) => {
        console.log(data);
        if (data.code == 0) {
            alert("登录成功，点击确定即将跳转首页");
            location.href = "index.html";
        }
        else {
            txtLoginId.p.innerText = data.msg;
        }
    });
}